import { createStore, applyMiddleware, compose } from 'redux'

// 中间件
import thunk from 'redux-thunk'
import promise from 'redux-promise'
// import saga from 'redux-saga'

// reducer
import reducer from './reducer'

// https://github.com/zalmoxisus/redux-devtools-extension
// 使用安装的tools或者compose
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
// composeEnhancers=>包裹中间件才能使redux-devtools生效=>上线时不包裹即可
const store = createStore(reducer, /* preloadedState, */ composeEnhancers(
  // applyMiddleware(thunk, promise, saga)
  applyMiddleware(thunk, promise)
));

export default store
